<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编写组件</title>
</head>

<body>
    <div id="app"></div>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <!-- es6 出来的时候有了js的类 -->
    <script type="text/babel">
    // 定义自己的类,去继承React.Component,重写render
        class Mycomponent extends React.Component {
            // 在类里边定义的需要加this
            mgs = "我是定义的变量";
            // 不想加this 在render里边定义
            show() {
                return <div> 我是类里边的方法</div>
            }
            render() {   
                // 局部变量              
                return <h1>{this.show()}</h1>
            }
        }
        ReactDOM.render(<Mycomponent/>,document.getElementById("app"))

    </script>
</body>

</html>